package com.ruoyi.manager.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.manager.domain.SoldierSpecialCare;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manager.mapper.SoldierRetirementMapper;
import com.ruoyi.manager.domain.SoldierRetirement;
import com.ruoyi.manager.service.ISoldierRetirementService;

/**
 * 军休安置Service业务层处理
 *
 * @author Allen
 * @date 2021-08-31
 */
@Service
public class SoldierRetirementServiceImpl implements ISoldierRetirementService {
    @Autowired
    private SoldierRetirementMapper soldierRetirementMapper;

    /**
     * 查询军休安置
     *
     * @param id
     *         军休安置主键
     *
     * @return 军休安置
     */
    @Override
    public SoldierRetirement selectSoldierRetirementById(Long id) {
        return soldierRetirementMapper.selectSoldierRetirementById(id);
    }

    /**
     * 查询军休安置列表
     *
     * @param soldierRetirement
     *         军休安置
     *
     * @return 军休安置
     */
    @Override
    public List<SoldierRetirement> selectSoldierRetirementList(SoldierRetirement soldierRetirement) {
        return soldierRetirementMapper.selectSoldierRetirementList(soldierRetirement);
    }

    /**
     * 新增军休安置
     *
     * @param soldierRetirement
     *         军休安置
     *
     * @return 结果
     */
    @Override
    public int insertSoldierRetirement(SoldierRetirement soldierRetirement) {
        soldierRetirement.setCreateTime(DateUtils.getNowDate());
        return soldierRetirementMapper.insertSoldierRetirement(soldierRetirement);
    }

    /**
     * 修改军休安置
     *
     * @param soldierRetirement
     *         军休安置
     *
     * @return 结果
     */
    @Override
    public int updateSoldierRetirement(SoldierRetirement soldierRetirement) {
        return soldierRetirementMapper.updateSoldierRetirement(soldierRetirement);
    }

    /**
     * 批量删除军休安置
     *
     * @param ids
     *         需要删除的军休安置主键
     *
     * @return 结果
     */
    @Override
    public int deleteSoldierRetirementByIds(Long[] ids) {
        return soldierRetirementMapper.deleteSoldierRetirementByIds(ids);
    }

    /**
     * 删除军休安置信息
     *
     * @param id
     *         军休安置主键
     *
     * @return 结果
     */
    @Override
    public int deleteSoldierRetirementById(Long id) {
        return soldierRetirementMapper.deleteSoldierRetirementById(id);
    }

    @Override
    public int audit(Long id, Integer auditStatus) {
        SoldierRetirement soldierRetirement = new SoldierRetirement();
        soldierRetirement.setId(id);
        soldierRetirement.setAuditStatus(auditStatus);
        soldierRetirement.setAuditId(SecurityUtils.getUserId());
        return soldierRetirementMapper.updateSoldierRetirement(soldierRetirement);
    }
}
